package core.network.client2game.handler.ddz;

import business.ddz.c2s.iclass.CDDZ_OpCard;
import business.global.pk.ddz.DDZRoom;
import business.global.room.RoomMgr;
import business.player.Player;
import com.ddm.server.websocket.def.ErrorCode;
import com.ddm.server.websocket.exception.WSException;
import com.ddm.server.websocket.handler.requset.WebSocketRequest;
import com.google.gson.Gson;
import core.network.client2game.handler.PlayerHandler;

import java.io.IOException;

/**
 * 安岳跑的快打牌
 */
public class CDDZOpCard extends PlayerHandler {

    @Override
    public void handle(Player player, WebSocketRequest request, String message) throws WSException, IOException {
        final CDDZ_OpCard clientPack = new Gson().fromJson(message, CDDZ_OpCard.class);

        DDZRoom room = (DDZRoom) RoomMgr.getInstance().getRoom(clientPack.roomID);
        if (null == room) {
            request.error(ErrorCode.NotAllow, "CDDZOpCard not find room:" + clientPack.roomID);
            return;
        }
        room.onOpCard(request, clientPack);
    }
}
